package com.lixinkeji.data;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.Nullable;

import com.previewlibrary.enitity.IThumbViewInfo;


@SuppressLint("ParcelCreator")
public class ImageInfo implements Parcelable, IThumbViewInfo {
    public String url;
    public Rect bounds;

    @Override
    public String getUrl() {
        return url;
    }

    @Override
    public Rect getBounds() {
        return bounds;
    }

    @Nullable
    @Override
    public String getVideoUrl() {
        return null;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(url);
        dest.writeValue(bounds);
    }

    public static final Parcelable.Creator<ImageInfo> CREATOR = new Creator(){

        @Override
        public ImageInfo createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            // 必须按成员变量声明的顺序读取数据，不然会出现获取数据出错
            ImageInfo p = new ImageInfo();
            p.url = source.readString();
            p.bounds = (Rect) source.readValue(null);
            return p;
        }

        @Override
        public ImageInfo[] newArray(int size) {
            // TODO Auto-generated method stub
            return new ImageInfo[size];
        }
    };

}
